<?php
    require_once('../code/global.php');
    require_once('/code/Admin.php');
    require_once('/code/Artist.php');
    $admin=new Admin();
    $admin->loginCheck(1);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>PhotoFromThe1st 后台管理系统</title>
        <link rel="stylesheet" href="/styles/admin.css" type="text/css" media="all">
        <script type="text/javascript" src="/script/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="/script/script.js"></script>
    </head>
    <body OnLoad="document.editArtist.name.focus();">
        <?php
            if(isset($_GET['msg'])) echo '<div class="msgBox">'.$_GET['msg'].'</div>';
            else echo '<div class="msgBox">摄影师管理</div>';
                
        ?>
        <table border="0" cellspacing="0" cellpadding="0" class="detailTable">
            <tr class="header"><td>Photographer</td><td>Photo Num.</td><td>Active</td><td>Actions</td></tr>
            <form name="addArtist" action="../code/exec.php" method="post"><input type="hidden" name="action" value="addArtist"><tr><td><input type="text" name="name" maxlength="64" class="nameBox"></td><td class="align-center">-</td><td class="align-center"><input name="is_active" type="checkbox" checked></td><td class="btnTd"><input class="btnLnk" type="submit" name="add" value="Add"></td></tr></form>
            <tr><td class="seperator" colspan="4"></td></tr>
<?php
    $edit_id=0;
    if(isset($_GET['edit_id'])) $edit_id=intval($_GET['edit_id']);
    $artist=new Artist();
    $a=$artist->getArtists(0);
    $a_count=count($a);
    $i=0;
    while($i<$a_count){
        if($a[$i]['artist_id']==$edit_id) {
            echo '<form name="editArtist" action="../code/exec.php" method="post"><input type="hidden" name="action" value="editArtist"><input type="hidden" name="artist_id" value="'.$a[$i]['artist_id'].'"><tr><td><input type="text" name="name" value="'.$a[$i]['name'].'" maxlength="64" class="nameBox"></td><td class="align-center">'.$a[$i]['item_count'].'</td><td class="align-center"><input name="is_active" type="checkbox" '.($a[$i]['is_active']?'checked':'').'></td><td class="btnTd"><input class="btnLnk" type="submit" name="save" value="Save"><input class="btnLnk" type="reset" name="reset" value="Reset"><input class="btnLnk" type="button" name="cancel" value="Cancel" onclick="location.href=\'photographer.html\'"></td></tr></form>';
        }
        else {
            echo '<form name="deleteArtist'.$a[$i]['artist_id'].'" action="../code/exec.php" method="post"><tr><td>'.$a[$i]['name'].'</td><td class="align-center">'.$a[$i]['item_count'].'</td><td class="align-center"><input type="checkbox" disabled '.($a[$i]['is_active']?'checked':'').'></td><td class="btnTd"><input class="btnLnk" type="button" value="Edit" onclick="location.href=\'?edit_id='.$a[$i]['artist_id'].'\'"><input type="hidden" name="action" value="deleteArtist"><input type="hidden" name="artist_id" value="'.$a[$i]['artist_id'].'"><input class="btnLnk btnDel" type="submit" value="Delete"'.($a[$i]['item_count']==0?'':'disabled').'></td></tr></form>';
        }
        ++$i;
    }
?>
    </table>
    </body>
</html>
